<html>
<head><meta charset="utf-8"><title>Prelude breakage with wildcard imports · t-libs · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/index.html">t-libs</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports.html">Prelude breakage with wildcard imports</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="229372006"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Prelude%20breakage%20with%20wildcard%20imports/near/229372006" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports.html#229372006">(Mar 08 2021 at 20:55)</a>:</h4>
<p>We've been talking a lot lately about the prelude, and we've gone with the premise that adding things other than traits to the prelude won't ever break anything, because people can just shadow the names we add.</p>



<a name="229372076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Prelude%20breakage%20with%20wildcard%20imports/near/229372076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports.html#229372076">(Mar 08 2021 at 20:56)</a>:</h4>
<p>However, see <a href="https://github.com/rust-lang/rust/pull/82770#issuecomment-792999294">https://github.com/rust-lang/rust/pull/82770#issuecomment-792999294</a> for a counterexample.</p>



<a name="229372168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Prelude%20breakage%20with%20wildcard%20imports/near/229372168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports.html#229372168">(Mar 08 2021 at 20:57)</a>:</h4>
<p>If someone does a wildcard import <code>use some_crate::*;</code>, and we export a name from the prelude that <code>some_crate</code> exported, that'll break the code with the wildcard import.</p>



<a name="229372242"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Prelude%20breakage%20with%20wildcard%20imports/near/229372242" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports.html#229372242">(Mar 08 2021 at 20:57)</a>:</h4>
<p>1) Is this a known issue?<br>
2) Do we consider this "acceptable breakage", and should we?<br>
3) Should we take this into account when considering prelude additions?</p>



<a name="229372273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Prelude%20breakage%20with%20wildcard%20imports/near/229372273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports.html#229372273">(Mar 08 2021 at 20:57)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="116883">@tmandry</span> <span class="user-mention" data-user-id="310399">@Mara</span></p>



<a name="229372376"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Prelude%20breakage%20with%20wildcard%20imports/near/229372376" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports.html#229372376">(Mar 08 2021 at 20:58)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="130111">@anp</span></p>



<a name="229372381"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Prelude%20breakage%20with%20wildcard%20imports/near/229372381" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports.html#229372381">(Mar 08 2021 at 20:58)</a>:</h4>
<p>we were just talking about this</p>



<a name="229372398"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Prelude%20breakage%20with%20wildcard%20imports/near/229372398" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports.html#229372398">(Mar 08 2021 at 20:58)</a>:</h4>
<p>This only applies to macros though.<br>
(And to imports, but for imports such restrictions are artificial and unnecessary - <a href="https://github.com/rust-lang/rust/issues/56414">#56414</a>.)</p>



<a name="229372450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Prelude%20breakage%20with%20wildcard%20imports/near/229372450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports.html#229372450">(Mar 08 2021 at 20:59)</a>:</h4>
<p>it interacts very badly with the <code>test_case</code> macro crate, which puts your code inside a module with <code>use super::*;</code></p>



<a name="229372793"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Prelude%20breakage%20with%20wildcard%20imports/near/229372793" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports.html#229372793">(Mar 08 2021 at 21:01)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports/near/229372242">said</a>:</p>
<blockquote>
<p>2) Do we consider this "acceptable breakage", and should we?</p>
</blockquote>
<p>I think it has to be "minor (acceptable) breakage", under the general rule: we're allowed to add things (to avoid stagnation) and there's a more-specific way to write it that works before and after the change.</p>



<a name="229372911"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Prelude%20breakage%20with%20wildcard%20imports/near/229372911" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports.html#229372911">(Mar 08 2021 at 21:01)</a>:</h4>
<p><span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> Is it fundamental for macros, or theoretically fixable?</p>



<a name="229373039"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Prelude%20breakage%20with%20wildcard%20imports/near/229373039" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports.html#229373039">(Mar 08 2021 at 21:02)</a>:</h4>
<p>(Eliminating it for imports might be worth considering at this point, but I'd like to leave that for a different thread.)</p>



<a name="229373169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Prelude%20breakage%20with%20wildcard%20imports/near/229373169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports.html#229373169">(Mar 08 2021 at 21:03)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116883">tmandry</span> <a href="#narrow/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports/near/229372450">said</a>:</p>
<blockquote>
<p>it interacts very badly with the <code>test_case</code> macro crate, which puts your code inside a module with <code>use super::*;</code></p>
</blockquote>
<p>A test module with <code>use super::*;</code> is a common pattern even without that macro.</p>



<a name="229373298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Prelude%20breakage%20with%20wildcard%20imports/near/229373298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports.html#229373298">(Mar 08 2021 at 21:04)</a>:</h4>
<p><span class="user-mention" data-user-id="125270">@scottmcm</span> Perhaps, but if it's something we can fix in the compiler to avoid such breakage, that seems like it'd be even better.</p>



<a name="229375038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Prelude%20breakage%20with%20wildcard%20imports/near/229375038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports.html#229375038">(Mar 08 2021 at 21:15)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports/near/229372911">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="123856">Vadim Petrochenkov</span> Is it fundamental for macros, or theoretically fixable?</p>
</blockquote>
<p>I'd say fundamental.</p>



<a name="229375767"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Prelude%20breakage%20with%20wildcard%20imports/near/229375767" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports.html#229375767">(Mar 08 2021 at 21:20)</a>:</h4>
<p><span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> What about macros makes it unfixable there, as compared to with functions?</p>



<a name="229375964"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Prelude%20breakage%20with%20wildcard%20imports/near/229375964" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports.html#229375964">(Mar 08 2021 at 21:21)</a>:</h4>
<p>Is this about non-hygienic references to things from macros? (e.g. <code>pub use some::macro</code> and provide different versions of the macros it calls, which makes a re-export not identical)</p>



<a name="229376541"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Prelude%20breakage%20with%20wildcard%20imports/near/229376541" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports.html#229376541">(Mar 08 2021 at 21:24)</a>:</h4>
<p>Macros are resolved/expanded early when the crate structure is still in flux, an can produce other modules/imports/macros after expansion, this imposes some restrictions.<br>
Functions calls are resolved late, when all crate structure is already built and frozen.</p>



<a name="229377263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Prelude%20breakage%20with%20wildcard%20imports/near/229377263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports.html#229377263">(Mar 08 2021 at 21:28)</a>:</h4>
<p>I see. Thanks for the explanation.</p>



<a name="229382529"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Prelude%20breakage%20with%20wildcard%20imports/near/229382529" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports.html#229382529">(Mar 08 2021 at 22:03)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports/near/229373298">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="125270">scottmcm</span> Perhaps, but if it's something we can fix in the compiler to avoid such breakage, that seems like it'd be even better.</p>
</blockquote>
<p>Yeah; my statement was just answering the specific question in isolation.  (And additions like <code>Unpin</code> mean it's defacto allowed breakage.)</p>
<p>Certainly an ambiguity resolution strategy in the compiler would be good too.  (Under obvious assumptions like it should be clear to users, resistant to permutations of <code>use</code>s, etc.)  I just don't think that I'd personally want to block a prelude addition on that existing, unless the breakage was particularly bad in practice.</p>



<a name="229383035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Prelude%20breakage%20with%20wildcard%20imports/near/229383035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports.html#229383035">(Mar 08 2021 at 22:05)</a>:</h4>
<p>"particularly bad in practice" was precisely my concern; previously, we just were assuming that additions to the prelude that weren't traits didn't even need a crater run.</p>



<a name="229383087"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Prelude%20breakage%20with%20wildcard%20imports/near/229383087" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports.html#229383087">(Mar 08 2021 at 22:05)</a>:</h4>
<p>Now, I think it makes sense to run macro additions through crater too.</p>



<a name="229383903"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Prelude%20breakage%20with%20wildcard%20imports/near/229383903" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports.html#229383903">(Mar 08 2021 at 22:08)</a>:</h4>
<p><span class="user-mention" data-user-id="116883">@tmandry</span> If you're interested, it sounds like your team could provide a PR to <a href="https://github.com/SimonSapin/rust-std-candidates/issues/22">https://github.com/SimonSapin/rust-std-candidates/issues/22</a> that would allow your existing code to compile without having to change.</p>



<a name="229389959"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Prelude%20breakage%20with%20wildcard%20imports/near/229389959" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports.html#229389959">(Mar 08 2021 at 22:45)</a>:</h4>
<p>Ah I'd thought about that but didn't think we could do it with nightlies. Now I realize there is a date in the output of <code>rustc --version</code> we could use.</p>



<a name="229390072"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Prelude%20breakage%20with%20wildcard%20imports/near/229390072" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports.html#229390072">(Mar 08 2021 at 22:46)</a>:</h4>
<p>it's not a perfect solution given that we build our own toolchain and won't necessarily use the exact same commit for a given date but it should be good enough.</p>



<a name="229390169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Prelude%20breakage%20with%20wildcard%20imports/near/229390169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports.html#229390169">(Mar 08 2021 at 22:46)</a>:</h4>
<p>still, I think this is going to create some unfortunate breakage for folks with a confusing error message</p>



<a name="229391174"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Prelude%20breakage%20with%20wildcard%20imports/near/229391174" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports.html#229391174">(Mar 08 2021 at 22:54)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116883">tmandry</span> <a href="#narrow/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports/near/229389959">said</a>:</p>
<blockquote>
<p>Ah I'd thought about that but didn't think we could do it with nightlies. Now I realize there is a date in the output of <code>rustc --version</code> we could use.</p>
</blockquote>
<p>I'm not suggesting checking the date; I'd suggest test-compiling a small Rust program that uses the feature flag and macro, and seeing if it works.</p>



<a name="229396469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Prelude%20breakage%20with%20wildcard%20imports/near/229396469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports.html#229396469">(Mar 08 2021 at 23:36)</a>:</h4>
<p>oh I see, that works too</p>



<a name="229396504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Prelude%20breakage%20with%20wildcard%20imports/near/229396504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Prelude.20breakage.20with.20wildcard.20imports.html#229396504">(Mar 08 2021 at 23:37)</a>:</h4>
<p><span class="user-mention" data-user-id="130111">@anp</span> also opened <a href="https://github.com/rust-lang/rust/issues/82913">#82913</a> to talk about this from the rust side</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>